Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Category
Bug fix
Feature/Issue Description
Issue described here: #3219
Test Cases
Launch beef on 127.0.0.1 port 3000, hook a browser on 127.0.0.1 (tested on firefox linux), right click browser and select "Use as proxy" now run:
http_proxy=http://127.0.0.1:6789 curl http://127.0.0.1:3000/
To test https proxying first run:
openssl s_server -key beef_key.pem -cert beef_cert.pem -accept 4433 -www
Then
http_proxy=http://127.0.0.1:6789 curl -k https://127.0.0.1:4433/
(Note if you get
Unsupported response code in HTTP response
your browser is likely hooked to localhost and you try to access 127.0.0.1 in such cases the proxy returnsWhich we might want to fix to be visible in curl by using proper status codes and error messages.)
Both return expected website data.
Rake results:
Technical issue and solution
The previous version relied on the fact that ruby allowed reading raw data from the SSLSocket before the handshake. This was used to initialize the proxy in plain text and then only perform a ssl/tls handshake if a CONNECT method was used by the client. (note socket.accept for a SSLSocket means "perform ssl/tls handshake").
This does not work anymore so instead we use a regular TCP server up until the point where SSLSocket is actually needed.